import request from "@/utils/request";
import { stringify } from 'qs';

const mockURL = "http://127.0.0.1:4523/m1/4124772-0-default";

//订单主列表
export function getOrderList(params) {
	return request(`/new-oms-search/esOrder/queryESOrder`, {
		method: "POST",
		data: params
		// baseURL: mockURL,
	});
}

//订单主列表(历史订单)
export function getHistoryOrderList(params) {
	return request(`/new-oms-search/esOrder/query/historyOrder`, {
		method: "POST",
		data: params
		// baseURL: mockURL,
	});
}

//批量选择发货仓订单统计：仅限待审核和异常状态的自发订单
export function getOrderIdsOp(params) {
  return request(`/new-oms-search/esOrder/queryBatchWarehouseESOrder`, {
    method: 'POST',
    data: params,
  });
}

//订单数量统计
export async function getStatisticsOp(params) {
	return request(`/new-oms-search/esOrder/statistics?${stringify(params)}`);
}

//Action////////////////////////////////////////////////////////////////////////////

//查询代发渠道多件订单限制
export async function queryMultiRule() {
	return request(`/zjf-oms/multiRule/find`);
}

//查询跑量商品
export async function getRunVolumeGoodsOp(type) {
  if(type == 'zifa'){
    return request(`/new-goods/goods/sku/running-volume-sku`);
  }
  return request(`/blade-goods/packagingGifts/getRunVolumeGoods`);
}

//发货仓
export function queryWarehouseList() {
  return request(`/zjf-wms/kx/warehouse/selectList`);
}

//发货仓(包含禁用)
export function queryAllWarehouse() {
  return request(`/zjf-wms/kx/warehouse/selectListSortInBan`);
}

//手工下单可用快递
export function queryCanUseExpressList(params) {
  return request(`/blade-logistics/expresskxerp/canUseExpressList`, {
    method: 'POST',
    data: params,
  });
}

//快递列表可用快递列表 0：自发可用，1：全部可用
export function queryExpressList(params) {
  return request(`/blade-logistics/expresskxerp/expressKv?${stringify(params)}`);
}

//手工下单
export function manualOrderOp(params) {
  return request(`/new-oms/order/add`, {
    method: 'POST',
    data: params,
  });
}

//手工同步订单
export function manualPullOrderOp(params) {
  return request(`/new-oms/order/hand/pull`, {
    method: 'POST',
    data: params,
  });
}

//修改发货仓
export function modifyWarehouseOp(params) {
  return request(`/new-oms/order/updateWarehouse`, {
    method: 'POST',
    data: params,
  });
}

//批量审核
export function batchAuditOp(params) {
  return request(`/new-oms/order/audit/batch`, {
    method: 'POST',
    data: params,
  });
}

//批量返审核金额确认
export function batchAuditConfirmOp(params) {
  return request(`/new-oms/order/returnAudit/batch/confirm?${stringify(params)}`);
}

//批量返审核
export function batchReturnAuditOp(params) {
  return request(`/new-oms/order/returnAudit/batch`, {
    method: 'POST',
    data: params,
  });
}

// 批量作废金额确认
export function batchInvalidConfirmOp(params) {
  return request(`/new-oms/order/invalid/batch/confirm`, {
    method: 'POST',
    data: params,
  });
}

// 批量作废 
export function batchInvalidOp(params) {
  return request(`/new-oms/order/invalid/batch`, {
    method: 'POST',
    data: params,
  });
}

//取消作废 
export function cancelInvalidOp(params) {
  return request(`/new-oms/order/invalid/cancel`, {
    method: 'POST',
    data: params,
  });
}

//批量转正常金额确认   
export function becomeNormalConfirmOp(params) {
  return request(`/new-oms/order/becomeNormal/batch/confirm`, {
    method: 'POST',
    data: params,
  });
}

//批量转正常  
export function becomeNormalOp(params) {
  return request(`/new-oms/order/becomeNormal/batch`, {
    method: 'POST',
    data: params,
  });
}

//批量转异常  
export function becomeErrorOp(params) {
  return request(`/new-oms/order/becomeError/batch`, {
    method: 'POST',
    data: params,
  });
}

//批量设跑量   
export function batchSetPacketOp(params) {
  return request(`/new-oms/order/setBatchPacket`, {
    method: 'POST',
    data: params,
  });
}

//批量取消跑量   
export function cancelRunVolumeOp(params) {
  return request(`/new-oms/order/cancelRunVolume`, {
    method: 'POST',
    data: params,
  });
}

//批量获取运单号    
export function getLogisticsNoOp(params) {
  return request(`/new-oms/order/getLogisticsNo`, {
    method: 'POST',
    data: params,
  });
}

//查看解密地址
export function getDecryptionAddressOp(params) {
  return request(`/new-oms-ec/order/getDecryptionAddress?${stringify(params)}`);
}


// 全部付款预览
export async function allPayView(params) {
	return request(`/new-oms/pay/all/pay/view`, {
		method: "post",
		data: params
	});
}

// 全部付款
export async function allPay(params) {
	return request(`/new-oms/pay/all/pay/real`, {
		method: "post",
		data: params
	});
}

// 批量付款预览
export async function batchPayView(params) {
	return request(`/new-oms/pay/batch/view`, {
		method: "post",
		data: params
	});
}

// 批量支付
export async function batchPayReal(params) {
	return request(`/new-oms/pay/batch/real`, {
		method: "post",
		data: params
	});
}

//查询支付中数量
export function unhappyTotal(params) {
    return request(`/new-oms/pay/unhappy/total?${stringify(params)}`);
  }

// 修改订单备注
export async function updateOrderRemarkOp(params) {
	return request(`/new-oms-ec/order/updateOrderRemark`, {
		method: "post",
		data: params
	});
}

// 修改卖家备注
export async function updateSellerRemarkOp(params) {
	return request(`/new-oms-ec/order/updateSellerRemark `, {
		method: "post",
		data: params
	});
}

// 取消运费拦截
export async function cancelFreightIntercept(params) {
	return request(`/new-oms/order/cancelFreightIntercept`, {
		method: "post",
		data: params
	});
}

// 取消运费拦截
export async function updateLogisticsOp(params) {
	return request(`/new-oms/order/updateLogistics`, {
		method: "post",
		data: params
	});
}

// 修改标签
export async function updateLabelOP(params) {
	return request(`/new-oms/order/updateLabel`, {
        method: "post",
		data: params
	});
}

//手动拆单
export async function manualSplitOrderOp(params) {
	return request(`/new-oms/orderSplitMerge/manualSplitOrder`, {
		method: "post",
		data: params
	});
}

//(手动合单)待合单列表 
export function waitMergeOrders(params) {
  return request(`/new-oms-search/esOrder/waitMergeOrders?${stringify(params)}`);
}

//查询标签列表
export function queryTagList(params) {
    return request(`/new-common/labelConfig/list?${stringify(params)}`);
  }

  // 设包装或赠品
export async function setBatchPackageGiftOp(params) {
	return request(`/new-oms/order/setBatchPackageGift`, {
		method: "post",
		data: params
	});
}

//手动合单
export async function manualMergeOrderOp(params) {
	return request(`/new-oms/orderSplitMerge/manualMergeOrder`, {
		method: "post",
		data: params
	});
}

//智能合单
export async function manualAutoMergeOrderOp(params) {
	return request(`/new-oms/orderSplitMerge/manualAutoMergeOrder`, {
		method: "post",
		data: params
	});
}

// 供应商下拉 (过滤同账号店铺)
export async function getzjfstoreList(params) {
    return request(`/blade-goods/zjfstore/list/fuzzyQueryPage?${stringify(params)}`);
  }

// 批量修改订单商品预览 
export async function modifyGoodsViewOp(params) {
	return request(`/new-oms/order/updateOrderGoods/batch`, {
		method: "post",
		data: params
	});
}

// 批量修改订单商品预览 
export async function batchExchangeGoods(params) {
	return request(`/new-oms/orderGoods/batch/exchange/orderGoods`, {
		method: "post",
		data: params
	});
}

// 批量修改订单商品 
export async function modifyGoodsOp(params) {
	return request(`/new-oms/order/updateOrderGoods/batch/confirm`, {
		method: "post",
		data: params
	});
}
// 保存公式 
export async function saveFormulaApi(params) {
	return request(`/new-oms/order/updateOrderGoods/batch/confirm`, {
		method: "post",
		data: params
	});
}

//未匹配商品明细
export async function getUnMatchGoodsOp(params) {
	return request(`/new-oms-search/esOrder/query/supplier/info`, {
		method: "post",
		data: params
	});
}

//查询供应商匹配统计
export function getInfoCount(params) {
	return request(`/new-oms-search/esOrder/query/supplier/info-count?${stringify(params)}`);
}

//供应商匹配
export async function supplierMatchOp(params) {
	return request(`/new-oms/order/supplierMatch`, {
		method: "post",
		data: params
	});
}

// 修改收件地址
export function saveOrderAddress(params) {
    return request('/new-oms-ec/order/updateDeliveryInfo', {
        method: "post",
        data: params,
    });
}

//解除匹配
export async function relieveMatch(params) {
	return request(`/new-oms/order/cancelMatch`, {
		method: "post",
		data: params
	});
}

//修改商品
export async function singleUpdateOrderGoods(params) {
	return request(`/new-oms/orderGoods/update/orderGoods`, {
		method: "post",
		data: params
	});
}

//修改商品确认
export async function sureUpdateOrderGoods(params) {
	return request(`/new-oms/orderGoods/update/orderGoods/confirm`, {
		method: "post",
		data: params
	});
}

//(新增/编辑)系统商品分类属性
export async function modifyGoodsAttributeOp(params) {
	return request(`/new-oms/orderGoods/update/sysGoodsName`, {
		method: "post",
		data: params
	});
}

// 查询导出字段映射
export async function queryFieldMappingConfig(params) {
    return request(`/new-common/fieldMappingConfig/getFieldMappingConfig?${stringify(params)}`);
  }

//修改导出字段映射
export async function fieldMappingConfigSave(params) {
	return request(`/new-common/fieldMappingConfig/update`, {
		method: "post",
		data: params
	});
}

//创建导出任务
export async function createExportTask(params) {
	return request(`/blade-log/taskInfo/createExportTask`, {
		method: "post",
		data: params
	});
}

//获取匹配供应商商品信息
export async function getMatchInfo(params) {
	return request(`/new-goods/goods/sku/get-match-info`, {
		method: "post",
		data: params
	});
}

//输入运单号批量
export async function batchInputLogisticsNoOp(params) {
	return request(`/new-oms-ec/orderlogistics/inputLogisticsNoBatch`, {
		method: "post",
		data: params
	});
}

//打单发货分页
export async function getOrderShipList(params) {
	return request(`/new-oms-search/esOrder/hotPrint/page`, {
		method: "post",
		data: params
	});
}

	//打单发货统计
	export async function getHotStatisticsOp(type, timeOutSetting, pickUptimeOutSetting){
		if(type == 1){
		  return request(`/new-oms-search/esOrder/count/unreviewedTab?${stringify({ timeOutSetting })}`);
		}else if(type == 2){
			return request(`/new-oms-search/esOrder/count/noShipTab`);
		}else{
		  return request(`/new-oms-search/esOrder/count/shipTab?${stringify({ timeOutSetting: pickUptimeOutSetting })}`);
		}
	}

	//爆款商品查询
	export async function getFashionGoodsOp(params){
		return request(`/new-oms-search/esOrder/hotGoods/page?${stringify(params)}`);
	}

	//爆款商品查询  根据sysSpuId获取商品颜色规格
	export async function getHotGoodsSpecOp(params){
		return request(`/new-oms-search/esOrder/hotGoods/getGoodsSpec`,{
			method: "post",
		  data: params
		});
	}

 //前端解密完成上传日志
 export async function decryptLogUpload(params) {
    return request(`/blade-goods/taobao/rect/decryptLogUpload`, {
        method: 'POST',
        data: params,
      });
  }

  // 整合不同三方平台的地址库（省市区，部分三方平台的地址库特殊处理）
export async function getAllArea(params) {
    return request(`/new-oms-ec/area/all?${stringify(params)}`);
  }

	//跑量可用快递列表
	export async function paoExpressKvOp(params) {
    return request(`/blade-logistics/expresskxerp/paoExpressKv?${stringify(params)}`);
  }

//订单重算
export function orderReanalysis(params) {
    return request(`/new-oms/order/orderReanalysis`, {
      method: 'POST',
      data: params,
    });
  }

  //快捷查询列表
export function getQuickSearchList(params) {
    return request(`/new-common/quickSearch/config/list?${stringify(params)}`);
  }
  
  //新增快捷查询
export function addQuickSearchOp(params) {
    return request(`/new-common/quickSearch/config/save`, {
      method: 'POST',
      data: params,
    });
  }
  
//删除快捷查询
export function delQuickSearchOp(params) {
	return request(`/new-common/quickSearch/config/del?${stringify(params)}`);
}
